<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <title>腾讯广告算法大赛</title>
  <link href="css/index.css" rel="stylesheet" type="text/css" />
  <link href="css/common.css" rel="stylesheet" type="text/css" />
  <link rel="stylesheet" type="text/css" href="css/simditor.css" />
  <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/module.min.js"></script>
<script type="text/javascript" src="js/hotkeys.min.js"></script>
<script type="text/javascript" src="js/uploader.min.js"></script>
<script type="text/javascript" src="js/simditor.min.js"></script>
<script type="text/javascript" src="js/cos-js-sdk-v5.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</head>
<body>

<div id="wrapper" class="user-page score-page">
  <div class="page-header">
    <div class="logo"></div>
    <div class="menu-btn">
      <div class="menu"></div>
    </div>
    <div class="nav">
      <ul class="navul">
        <a href="/application/home/home/index.html">
          <li>首页</li>
        </a>
        <a href="/application/home/home/index.html?p=introduce">
          <li>大赛介绍</li>
        </a>
        <a href="/application/home/information/info.html">
          <li>赛题说明</li>
        </a>
        <a href="/application/home/introduction/flow.html">
          <li>赛制流程</li>
        </a>
        <!--<a href="../../home/rankinglist/rankingList"><li>排行榜</li></a>-->
        <a href="/application/home/home/index.html?p=judges">
          <li>评委</li>
        </a>
        <a href="/application/home/home/awards.html">
          <li>奖项设置</li>
        </a>
        <a href="/application/home/home/index.html?p=partners">
          <li>合作伙伴</li>
        </a>
        <!-- <li>论坛</li> -->
        <a href="/application/notice/home/index.html">
          <li>大赛新闻</li>
        </a>

        <a href="/application/home/home/faq.html">
          <li>FAQ</li>
        </a>
        <a href="/application/home/home/review.html">
          <li>往期内容</li>
        </a>
        <a href="http://e.qq.com/jobs/" target="_blank">
          <li>招聘</li>
        </a>
        <!--<a href="/application/finale/home/invitation.html">-->
        <!--<li>决赛日报名</li>-->
        <!--</a>-->
        <li class="login isLogin" >
          <div class="lgi">登录</div>
        </li>
        <li class="login logged isUser">
          <a href="/application/person/home/user.html">
            <div class="lgd">个人信息</div>
          </a>
        </li>
        <li class="logout logged isOut">
          登出
        </li>
        <li class="switchLang"><img src="./img/zhEn.png" style="display: inline-block;width: 30px;margin-top: 5px;"></li>
      </ul>
    </div>
  </div>
  <!-- pc端 -->
  <div id="pc">
    <div class="container1">
      <h2>创建帖子</h2>
      <input class="title" type="text" placeholder="请输入标题...">
      <span class="sameSpan">富文本</span>
      <textarea id="editor"></textarea>
      <span class="sameSpan">标签</span>
      <div class="tab">
        <ul>
          <li class="inputLi">
            <input type="text">
          </li>
        </ul>
      </div>
      <div class="select">
        <span>标签:</span>
        <ul>
          <li>实验代码</li>
          <li>学习心得</li>
          <li>行业资讯</li>
          <li>招聘课程</li>
          <li>活动</li>
        </ul>
      </div>
      <span class="sameSpan">附件<p>格式支持：zip,csv,txt,pptx,pdf,xlsx,mp4,单个文件大小需小于100M</p></span>
      <div class="filewrap">
        <input type="file" class="upload" id="file-selector">
        <button>上传附件</button>
      </div>
      <div class="btnwrap">
        <button>发布</button>
        <button>保存</button>
      </div>
    </div>
  </div>
 <!-- 移动端 -->
 <div id="mobile">
  <div class="head1">
    <a href="">&lt;</a>
    <h1>新建帖子/文章</h1>
    <span>发布</span>
  </div>
  <input type="text" placeholder="标题（最多30个字）" maxlength="30">
  <textarea placeholder="请输入内容，内容不可为空"></textarea>
  <div class="uploadwrap">
    <input type="file" id="file-selector1">
    <button>+</button>
  </div>
  <span class="addtab">添加标签</span>
  <ul class="selectul"></ul>
    <ul class="tabul">
      <li>实验代码</li>
      <li>学习心得</li>
      <li>行业资讯</li>
      <li>招聘课程</li>
      <li>活动</li>
    </ul>
 </div>

  <div class="page-footer">
    Copyright © 1998 - 2019 Tencent Inc. All Rights Reserved. 腾讯公司 版权所有
  </div>
</div>

</body>
</html>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
  $('.page-header .menu-btn').click(function() {
    $('.page-header').toggleClass("open");
  });
  var editor = new Simditor({
    textarea: $('#editor')
    //optional options
});



  var Bucket = 'test-1250000000';
var Region = 'ap-guangzhou';

// 初始化实例
var cos = new COS({
    getAuthorization: function (options, callback) {
        var url = '../server/sts.php';
        var xhr = new XMLHttpRequest();
        xhr.open('GET', url, true);
        xhr.onload = function (e) {
            try {
                var data = JSON.parse(e.target.responseText);
            } catch (e) {
            }
            callback({
                TmpSecretId: data.credentials && data.credentials.tmpSecretId,
                TmpSecretKey: data.credentials && data.credentials.tmpSecretKey,
                XCosSecurityToken: data.credentials && data.credentials.sessionToken,
                ExpiredTime: data.expiredTime,
            });
        };
        xhr.send();
    }
});

// 监听选文件
document.getElementById('file-selector').onchange = function () {
    
    var file = this.files[0];
    if (!file) return;

    // 分片上传文件
    cos.sliceUploadFile({
        Bucket: Bucket,
        Region: Region,
        Key: file.name,
        Body: file,
        onHashProgress: function (progressData) {
            console.log('校验中', JSON.stringify(progressData));
        },
        onProgress: function (progressData) {
            console.log('上传中', JSON.stringify(progressData));
        },
    }, function (err, data) {
        console.log(err, data);
    });


};
//判断是否为pc端
    var head = document.getElementsByTagName('head')[0];
    var link = document.createElement('link');

    function IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    }

    function removejscssfile(filename, filetype) {
        var targetelement = (filetype == "js") ? "script" : (filetype == "css") ? "link" : "none";
        var targetattr = (filetype == "js") ? "src" : (filetype == "css") ? "href" : "none";
        var allsuspects = document.getElementsByTagName(targetelement);
        for (var i = allsuspects.length; i >= 0; i--) {
            if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].getAttribute(targetattr).indexOf(filename) != -1)
                allsuspects[i].parentNode.removeChild(allsuspects[i]);
        }
    }
    var pcAndMobile = true;
    if (IsPC()) {
        pcAndMobile = true;
        $("#pc").show();
        $("#mobile").hide();
    } else {
       $("#pc").hide();
        $("#mobile").show();
        $("body").css("background","#f5f5f9")
    }
</script>
